package com.codedog.entity.properties;

import cn.hutool.core.util.StrUtil;
import com.codedog.constant.BeanNameConstant;
import com.codedog.utils.CodeDogCookieUtil;
import lombok.Data;
import org.springframework.stereotype.Component;

@Component(BeanNameConstant.COMPLETION_RATE)
@Data
public class CompletionRate {

    private Boolean isRecord = false;
    //小试牛刀已完成
    private Integer tobStatusDone = 0;
    //拓展创作已完成
    private Integer homeworkStatusDone = 0;
    //语音周报已打开
    private Integer voiceWeeklyStatusDone = 0;
    //班级总人数
    private Integer studentTotal = 0;
    private String cookie;
    private Boolean isAdmin = false;
    private String admin = "李修广";


    public void initCompletionRate() {
        this.isRecord = false;
        this.studentTotal = 0;
        this.tobStatusDone = 0;
        this.homeworkStatusDone = 0;
        this.voiceWeeklyStatusDone = 0;
    }

    public void addTobStatusDone() {
        if (this.isRecord) {
            this.tobStatusDone = this.tobStatusDone + 1;
        }
    }

    public void addHomeworkStatusDone() {
        if (this.isRecord) {
            this.homeworkStatusDone = this.homeworkStatusDone + 1;
        }
    }

    public void addVoiceWeeklyStatusDone() {
        if (this.isRecord) {
            this.voiceWeeklyStatusDone = this.voiceWeeklyStatusDone + 1;
        }
    }

    public String getCookie() {
        String newCookie = null;
        if (StrUtil.isEmpty(this.cookie)) {
            newCookie = CodeDogCookieUtil.getCookie();
            this.cookie = newCookie;
        }
        return this.cookie;
    }


}
